<?php
/*------------------------------------------------------------------------
 * UserMessageController.class.php 
 *
 * 我的消息
 * 	
 * Created on 2016-07-30
 *
 * Author: hwc123 <hwc123@139.com>
 * 
 * Copyright (c) 2016 All rights reserved.
 * ------------------------------------------------------------------------
 */

namespace Home\Controller;
class UserMessageController extends CommonController{

	public function _initialize(){
		parent::_initialize();
		$this->user_id();
		$this->add_step('消息管理', U('index'));
	}

	public function index(){
		$page      = $this->_get('p', '', 1);
		$pagesize  = 10;
		$first_row = $pagesize * ($page - 1);

		$this->add_step('我的消息');
		// 按消息类型
		$message_type = $this->_get("msg_type");
		if($message_type){
			$where['msg_type']	= $message_type;
		}	

		$where['user_id'] = $this->user_id;
		$count = D('MessageLog')->where($where)->count();
		$list  = D('MessageLog')->where($where)->limit($first_row . ',' . $pagesize)->order('log_id desc')->select();
		
		//处理AJAX分页
		$this->page($new_list, $count);
		$this->assign('list', $list);
		$this->display();
	}
}